package com.xxc.test.domain.repository;

import com.xxc.domain.strategy.model.entity.StrategyRuleEntity;
import com.xxc.domain.strategy.repository.IStrategyRepository;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;
import java.util.Deque;

/**
 * @Author: xxc
 * @Description: 策略仓储测试
 * @Date: 2025/1/21 22:47
 * @Version: 1.0
 */

@Slf4j
@RunWith(SpringRunner.class)
@SpringBootTest
public class StrategyRepositoryTest {

    @Resource
    private IStrategyRepository strategyRepository;

    @Test
    public void test_getRuleWeight() {
        StrategyRuleEntity strategyRuleEntity = strategyRepository.queryStrategyRule(100001L,"rule_weight");
        String ruleValue = strategyRuleEntity.getRuleValue();
        String[] ruleWeights = ruleValue.split(" ");
        for (String ruleWeight : ruleWeights) {
            String[] creditAndWeights = ruleWeight.split(":");
            String creditBoundary = creditAndWeights[0];
            String[] awardIds = creditAndWeights[1].split(",");

            System.out.println("creditBoundary = " + creditBoundary);
            for (int i = 0; i < awardIds.length; i++) {
                System.out.println("awardId" + i + "= " + awardIds[i]);
            }
        }
    }
}
